package com.mybatis.jpa.utils;

import org.apache.commons.lang3.time.StopWatch;

public class StopWatchExt extends StopWatch {

    /**
     * 初始化时默认start
     */
    public StopWatchExt() {
        this.start();
    }

    /**
     * 获取时间时判断是否重置
     *
     * @return
     */
    public long getTimeWithReset(boolean reset) {
        long time = super.getTime();

        if (reset) {
            this.reset();
            this.start();
        } else {
            this.stop();
        }

        return time;
    }
}
